const staff ={
  state:{
   listOfStaffs:[], //当前乐谱列表
    tempList:JSON.parse(localStorage.getItem('tempList') || '{}'),//单个乐谱集信息或乐谱的信息
    id:'',//乐谱或乐谱集id
  },
  getters : {
    listOfStaffs:state =>{
      let listOfStaffs = state.listOfStaffs
      if (!listOfStaffs.length){
        listOfStaffs = JSON.parse(localStorage.getItem('listOfStaffs')||null);
      }
      return listOfStaffs
    },
    tempList:state =>{
      let tempList = state.tempList
      if (!tempList){
        tempList = JSON.parse(localStorage.getItem('tempList'));
      }
      return tempList
    },
    id:state =>{
      let id = state.id
      if (!id){
        id = JSON.parse(localStorage.getItem('id'))
      }
      return id
    },
  },
  mutations:{
    setListOfStaffs:(state,listOfStaffs)=>{
      state.listOfStaffs = listOfStaffs
      localStorage.setItem('listOfStaffs',JSON.stringify(listOfStaffs))
    },
    setTempList:(state,tempList)=>{
      state.tempList = tempList
      localStorage.setItem('tempList',JSON.stringify(tempList))
    },
    setId:(state,id)=>{
      state.id = id
      localStorage.setItem('id',JSON.stringify(id))
    }
  }
}
export default staff

